
#include "StdAfx.h"
#include "CDMPlatformClient.h"
#include "menutext.h"

CMenuText::CMenuText(CMenu *pMenu)
{
	m_nTextIndex = 0;

	BuildMenuText(pMenu);
}

CMenuText::~CMenuText(void)
{
}

void CMenuText::BuildMenuText(CMenu * pMenu)
{
	MENUITEMINFO miif = {0};
	TCHAR szText[100]={0};

	miif.cbSize = sizeof(MENUITEMINFO);
	miif.fMask = MIIM_TYPE|MIIM_SUBMENU;
	miif.dwTypeData = szText;
	miif.cch = ARRAY_SIZE(szText)-1;

	for(UINT i = 0; pMenu->GetMenuItemInfo(i, &miif, TRUE); i++)
	{
		if(miif.fType == MFT_STRING)
		{
			LPCTSTR lpszText = LOAD_STRING(miif.dwTypeData);

			_tcsncpy_s(szText, lpszText, ARRAY_SIZE(szText)-1);

			miif.dwTypeData = szText;
			pMenu->SetMenuItemInfo(i, &miif, TRUE);
		}

		if(miif.hSubMenu)
		{
			BuildMenuText(CMenu::FromHandle(miif.hSubMenu));
		}

		miif.dwTypeData = szText;
		miif.cch = ARRAY_SIZE(szText)-1;
	}
}

